package by.semerikov.statictic;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import by.semerikov.parts.Code;
import by.semerikov.parts.Log;

public class StaticticByCode {
	
	private List<Log> list = new ArrayList<>();

	public StaticticByCode(List<Log> list) {
		super();
		this.setList(list);
	}
	
	public Map<Integer,Integer> getSortedByCode()
	{
		Map<Integer,Integer> result = new HashMap<Integer,Integer>();
		Integer key;
		for (int i = 0; i < Code.codes.length; i++) {
			key = Code.codes[i];
			Integer count = 0;
			for (int j = 0; j < list.size(); j++) {
				if(key.equals( Code.codes[list.get(j).getCode().getCode()]))
				{
					count ++;
				}
			}
			result.put(key, count);
		}
		return result;
	}

	public List<Log> getList() {
		return list;
	}

	public void setList(List<Log> list) {
		this.list = list;
	}
	
	

}
